package com.zq.api.task;

import java.time.LocalDateTime;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.zq.server.api.dao.ActivityMapper;
import com.zq.server.admin.dao.SysNotifyMapper;
import com.zq.server.core.sevcice.WebSocketServer;

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;

/**
 * 活动定时任务
 * @author Super
 */
@Component
@Slf4j
@Api(tags = "活动定时任务")
public class ActivityTask {
    @Autowired
    private ActivityMapper activityMapper;

    @Autowired
    private WebSocketServer socketServer;

    @Autowired
    private SysNotifyMapper notifyService;



    /**
     * @author 财哥
     * &#064;  2024.3.28 18:45
     * 两分钟执行一次处理活动
     **/
    @Scheduled(cron = " 0 */2 * * * ? ")
    public void SetActivityTaskAndTime() {
        /**
         * 活动状态 1报名中 2进行中 3已结束
         */
        // 查出未结束的所有活动
        int notFinishedActivityList = activityMapper.updateActivityState();
        log.info("{}个活动进行了修改 更新时间为{}", notFinishedActivityList, LocalDateTime.now());
    }


}
